<%@ page language="java" contentType="text/html" pageEncoding="utf-8"%>
<%@include file="/WEB-INF/pages/common/common.jsp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head> 
    <%@include file="/WEB-INF/pages/common/head.jsp"%>
    <%@include file="/resources/datepicker/datepicker.jsp"%> 
    <title><spring:message code="title.ipic.target"/></title>
      <style type="text/css">
        .font_stress{
            color: red;font-size: 13px;font-weight:bold;
        }
    </style>
    <script type="text/javascript">
        var operateDialog;
          var datagrid;
	        $(function() {
	            datagrid=$('#datagrid').datagrid({
	                onClickRow:function(rowIndex){
	                    var rows = datagrid.datagrid('getRows');
	                    for ( var i = 0; i < rows.length; i++) {
	                        datagrid.datagrid('endEdit', i);
	                    }
	                    datagrid.datagrid('beginEdit', rowIndex);
	                }
	            });
            
	        });
	        
	       function save_(){
	      
            imonJYRH.showZone();
            var rows = datagrid.datagrid('getRows');
            
            for ( var i = 0; i < rows.length; i++) {
		        datagrid.datagrid('endEdit', i);
		   	 }
            var effectData = new Object();
            effectData["incomingDetail"] = JSON.stringify(rows);
            effectData["incoming"] =  JSON.stringify(imonJYRH.serializeObject($("#tableForm *")));
            
            $.ajax({
                url : '${path}/business/ipic_system/incoming/ajaxModify.do',
                 data : effectData,
                 cache : false,
                 async : true,
                 dataType : "json",
                success : function(reMsg) {
                    if(reMsg.success){
                        parent.returnResult();
                        message.show({ msg : reMsg.msg,title : '<spring:message code='msg.tip'/>',showType:'slide'});
                    }else{
                        if(!imonJYRH.isBlank(reMsg.obj)){
                            $.messager.alert('<spring:message code='msg.tip'/>',reMsg['obj']);
                        }else{
                            $.messager.alert('<spring:message code='msg.tip'/>',reMsg['msg']);
                        }
                    }
                    imonJYRH.hideZone();
                }
            });
        }
   function dialogSupplier_(){
            var href = '${path}/basedata/supplier/dialogUI.do';
            operateDialog = $("#operateDialog").dialog({
                title : '<spring:message code='msg.dialog.choose'/>',
                width : 650,
                height : 400
            });
            $("#operateIFrame")[0].src=href;
            operateDialog.dialog('open');
        }
     function dialogSupplierReturn(row){
            $("#supplierId").val(row['id']);
            $("#supplierCode").val(row['code']);
            $("#supplierName").val(row['name']);
            operateDialog.dialog('close');
        }
    </script>
</head>
<body class="easyui-layout">
   <div data-options="region:'center'">
    <div class="datagrid-toolbar" style="height:450px">
         <table width="100%"  class="tableForm" id="tableForm">
            <tr>
                <td>
                    <span style="color:red;">*</span>供应商： 
                        <input type="hidden" id='supplierId' name="supplierId" value="${incomingVo.sid}"/>
                        <input type="text" id="supplierCode" onclick="dialogSupplier_();" readonly="true" value="${incomingVo.supplierCode}" disabled/>
                </td>
                <td>
                    SupplierName供应商名称： <input type="text" id="supplierName" style="width: 180px;" disabled value="${incomingVo.supplierName}"/>
                </td>
                <td>
                    <span style="color:red;">*</span>年份：&nbsp;&nbsp;&nbsp;&nbsp;  <input type="text" name="year" value="${incomingVo.year}" disabled
                               onFocus="WdatePicker({isShowClear:false,isShowToday:false,dateFmt:'yyyy',readOnly:true})" class="field Wdate" />
                               <input type="hidden" id='year' name="year" value="${incomingVo.year}"/>
                </td>
            </tr>
            <tr>
           		  <td>
                   <span style="color:red;">*</span> 零件号：
                    <input type="hidden" id="partId" name="partId" value="${incomingVo.pid}"/>
							                <input type="text" id="partCode"
							                       readonly class="easyui-validatebox" data-options="required:true" disabled value="${incomingVo.partNum}"/>
                </td>
                  <td>
                   零件名称：<input id="partName" type="text" disabled  name="partName" data-options="required:true" value="${incomingVo.partName}"/>
                </td>
            </tr>
        </table>
        <hr width="650px"/>
      <table width="100%" id="datagrid" singleSelect="true">
            <thead>
            <tr>
                <th field="month" width="60" hidden="true">月份</th>
                <th field="months" width="60">月份</th>
                <th field="amount" width="80" data-options="editor:{type:'numberbox',options:{min:0,precision:0}}">数量</th>
                <th field="comment" width="300" data-options="editor:{type:'text'}">评论</th>
            </tr>
            </thead>
            <tbody>
            <tr>
                <td hidden="true">01</td>
                <td>一月</td>
                <td>${incomingVo.january}</td>
                 <td>${incomingVo.januaryComment}</td>
            </tr>
            <tr>
               <td hidden="true">02</td>
                <td>二月</td>
                <td>${incomingVo.february}</td>
                <td>${incomingVo.februaryComment}</td>
            </tr>
            <tr>
              <td hidden="true">03</td>
                <td>三月</td>
               <td>${incomingVo.march}</td>
                <td>${incomingVo.marchComment}</td>
            </tr>
            <tr>
              <td hidden="true">04</td>
                <td>四月</td>
               <td>${incomingVo.april}</td>
                <td>${incomingVo.aprilComment}</td>
            </tr>
            <tr>
              <td hidden="true">05</td>
                <td>五月</td>
               <td>${incomingVo.may}</td>
                <td>${incomingVo.mayComment}</td>
            </tr>
            <tr>
              <td hidden="true">06</td>
                <td>六月</td>
                <td>${incomingVo.june}</td>
                <td>${incomingVo.juneComment}</td>
            </tr>
            <tr>
              <td hidden="true">07</td>
                <td>七月</td>
                <td>${incomingVo.july}</td>
                <td>${incomingVo.julyComment}</td>
            </tr>
            <tr>
              <td hidden="true">08</td>
                <td>八月</td>
               <td>${incomingVo.august}</td>
               <td>${incomingVo.augustComment}</td>
            </tr>
            <tr>
              <td hidden="true">09</td>
                <td>九月</td>
                <td>${incomingVo.september}</td>
                <td>${incomingVo.septemberComment}</td>
            </tr>
            <tr>
              <td hidden="true">10</td>
                <td>十月</td>
               <td>${incomingVo.october}</td>
               <td>${incomingVo.octoberComment}</td>
            </tr>
            <tr>
              <td hidden="true">11</td>
                <td>十一月</td>
               <td>${incomingVo.november}</td>
               <td>${incomingVo.novemberComment}</td>
            </tr>
            <tr hidden="true">
                <td>12</td>
                <td>十二月</td>
                <td>${incomingVo.december}</td>
                <td>${incomingVo.decemberComment}</td>
            </tr>
            </tbody>
        </table>
        <br />
        <div align="right">
            <a class="easyui-linkbutton" href="javascript:void(0);" iconCls="icon-save" onclick="save_();"><spring:message code='button.save'/></a>
            <a class="easyui-linkbutton" href="javascript:void(0);" iconCls="icon-no" onclick="parent.operateDialog.dialog('close');"><spring:message code='button.close'/></a>
        </div>
    </div>
</div>
<div id="operateDialog" class="easyui-dialog"
     data-options="iconCls:'icon-save',resizable:true,modal:true,closed: true,collapsible:true,maximizable:true">
    <iframe scrolling="auto" id='operateIFrame' frameborder="0"  src="" style="width:100%;height:100%;"/>
</div>
</body>
</html>